import { connect } from 'react-redux'
import Count from '../components/Count'

import { inc, dec } from '../redux/actions'
// 给Count创建父组件

// 是将redux中的数据,经过过滤传递给Count组件
function mapStateToProps(state) {
  return {
    c: state.count,
  }
}
// 是将调用disaptch方法封装起来,然后传递给Count组件
function mapDispatchToProps(dispatch) {
  return {
    add: function (num) {
      dispatch(inc(num))
    },
    sub: function (num) {
      dispatch(dec(num))
    },
  }
}
// 这是容器组件
const WithCount = connect(mapStateToProps, mapDispatchToProps)(Count)
export default WithCount
